<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>风味-找回密码</title>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" type="text/css" href="css/loginPublicStyle.css"/>
    <link rel="stylesheet" type="text/css" href="css/foundPwd.css"/>
    <script src="js/jquery-2.1.0.js"></script>
    <script>
        $(function(){
            var str=location.href; //获取本页url地址
            var arr=str.split("?");
            var str1 = arr[1];
            var userIdString = str1.split("=")[1];
            var userId = parseInt(userIdString);
//            console.log(userId);
            var pswBtn = $("#sub_againpwd");
//            点击事件，点击后开始向后台提交数据
            pswBtn.click(function(){
                var userPassword = $("#again_pwd").val();
                console.log(userPassword+">>>>>"+userId);
                $.ajax("/fengwei/user/update",{
                    type:"post",
                    data:{
                        'userId':userId,
                        'userPassword':userPassword
                    },
                    success:function(){
                        alert(1);
                    },
                    error:function(){
                        alert(0);
                    }
                })
            })
        })

    </script>
</head>
<body>
<a id="back">
    <a href="forgetpwd.html" id="back_a"><</a>
</a>

<div id="blackmask"><!--背景图上的黑色遮罩-->
</div>
<div id="login_bg"><!--login的背景-->
    <img src="img/login_bg.jpg"/>
</div>
<div id="againPwd">
    <form action="">
        <input type="password" name="again_pwd" id="again_pwd" value="" onblur="validateEmpty()"
               placeholder="请输入您的新密码"/>
        <br/><span id="again_pwd_span">
				
				</span>
        <input type="password" name="again_pwd1" id="again_pwd1" value="" placeholder="请确认您的新密码"
               onblur="validaterepeat()"/>
        <br/><span id="again_pwd1_span">
					
				</span>
        <input type="submit" name="sub_againpwd" id="sub_againpwd" value="提交" disabled="disabled"
               />
        <br/><span id="sub_againpwd_span">
					
				</span>
    </form>
</div>
<script type="text/javascript">
    function validateEmpty() {
        var again_pwd = document.getElementById('again_pwd');
        var again_pwd_span = document.getElementById('again_pwd_span');
        if (again_pwd.value != "") {
            again_pwd_span.innerHTML = "<font color='#21dcdd'>密码可用!</font>";
        } else {
            again_pwd_span.innerHTML = "<font color='red'>输入内容为空！</font>";
        }
    }


    function validaterepeat() {
        var sub_button = document.getElementById('sub_againpwd');
        var srcelement = document.getElementById("again_pwd");
        var deselement = document.getElementById("again_pwd1");
        var msgelement = document.getElementById("again_pwd1_span");
        if (srcelement.value == deselement.value && srcelement.value != "" && deselement.value != "") {
            msgelement.innerHTML = "<font color='#21dcdd'>密码相符！</font>";
            sub_button.disabled = false;
        } else {

            msgelement.innerHTML = "<font color='red'>两次输入密码不相符！</font>";
            sub_button.disabled = true;
        }

    }
//    function success_reg() {
//        var sub_button = document.getElementById('sub_againpwd');
//        if (sub_button.disabled == false) {
//            alert('密码修改成功！');
////            window.open('login.html');
//        }
//    }
</script>
</body>
</html>
